package com.vstyran.radio.vos
{
	public class Track
	{
		public function Track(name:String="", path:String="", isURL:Boolean = false)
		{
			this.path = path;
			this.name = name;
			this.isURL = isURL;
		}
		[Bindable]
		public var isURL:Boolean;
		
		[Bindable]
		public var path:String;
		[Bindable]
		public var name:String;
		
		public var numLike:Number = 0;
		public var numUnLike:Number = 0;
		
		private var metas:Vector.<MetaData> = new Vector.<MetaData>();
		
		public function addRating(meta:MetaData):void
		{
			if(meta.trackName == name)
			{
				for each (var m:MetaData in metas) 
				{
					if(m.peer == meta.peer)
					{
						m.like = meta.like;
						computeRating();
						return;
					}
					
				}
				metas.push(meta);
				computeRating();
			}
		}
		
		private function computeRating():void
		{
			var likeNum:Number = 0;
			for each (var m:MetaData in metas) 
			{
				if(m.like)
					likeNum++;
			}
			
			numLike = likeNum;
			numUnLike = metas.length - likeNum;
		}
		
	}
}